import React from 'react'
import { useLocation, useParams, useSearchParams } from 'react-router-dom'
// import qs from 'querystring'

export default function MessageDetail(props) {
  // 接收params参数
  // const params = useParams()
  // const {id, title, content} = params
  // 接收search参数
  /*
  const [searchParams] = useSearchParams()
  const id = searchParams.get("id")
  const title = searchParams.get("title")
  const content = searchParams.get("content")
  */
  /*
  qs将被废弃
  const params = qs.parse(searchParams.toString());
  const id = params.id
  const title = params.title
  const content = params.content
  */
 // 接收location.state参数
  const location = useLocation() || {}
  const {id, title, content} = location.state || {}

  return (
    <div>
      <ul>
        <li>id:{id}</li>
        <li>title:{title}</li>
        <li>content:{content}</li>
      </ul>
    </div>
  )
}